package day01;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class sleep_interrupt
{

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread("t1") {
            @Override
            public void run() {
                log.debug("enter sleep");
                try {
                    Thread.sleep(2000);
                    // 抛出一个打断异常
                } catch (InterruptedException e) {
                    log.debug("wake up.....");
                    throw new RuntimeException(e);
                }
            }
        };

        t1.start();
        Thread.sleep(1000);
        log.debug("interrupt.......");
        // 打断t1线程的休眠
        t1.interrupt();


    }
}
